Skip to content

Conversation

kgs233
Copy link

@kgs233 kgs233 commented Sep 17, 2024

portaudio-sharp uses LPStr as a string mapping method, this will lose some of the data for non-ANSI strings.
Changing the string mapping of the name member of PaDeviceInfo in portaudio-sharp from LPStr(ANSI) to LPWStr(Unicode) solves the problem perfectly.Changing the string mapping of the name member of PaDeviceInfo in portaudio-sharp from LPStr(ANSI) to LPWStr(Unicode) solves the problem perfectly.

@flipswitchingmonkey
Copy link
Owner

@vasilevp Do you want to review and merge it? I have moved almost entirely to MacOS and have not used flexASIO in ages, let alone worked on the repo...

@kgs233
Copy link
Author

kgs233 commented Sep 17, 2024

I think I may be mistaken about what's causing the problem, it's actually the fact that PortAudio no longer uses ANSI strings internally but Unicode strings instead, so that causes the old PortAudio-sharp string mapping to garble errors.
However, the code that needs to be merged is fine, but the logic of the fix is a bit wrong.

@dechamps
Copy link

PortAudio no longer uses ANSI strings internally but Unicode strings instead

PortAudio always returns device names as UTF-8, and as far as I know that has always been the case.

@kgs233
Copy link
Author

kgs233 commented Sep 17, 2024

PortAudio no longer uses ANSI strings internally but Unicode strings instead

PortAudio always returns device names as UTF-8, and as far as I know that has always been the case.

But I found something in PortAudio about ANSI string changing to UTF-8 string, so I'm guessing that a long time ago (when PortAudio-Sharp was developed) PortAudio used to use ANSI strings to return the device name.

@vasilevp
Copy link
Contributor

vasilevp commented Jun 5, 2025

@vasilevp Do you want to review and merge it? I have moved almost entirely to MacOS and have not used flexASIO in ages, let alone worked on the repo...

Hi! Bit late to the party...

I've also moved away from Windows some time ago (and stopped using flexASIO long before that).

I did, however, try to run this in a VM and got the following:

[output]
device = "Динамики (High Definition Audio Device)\u0000"

Note the \u0000 at the end that was not here before - looks like an off-by-1 error to me...

This trailing zero comes from Portaudio and only for this Cyrillic-named device in my case, so there's got to be some weirdness in there.

@kgs233
Copy link
Author

kgs233 commented Jun 6, 2025

@vasilevp Do you want to review and merge it? I have moved almost entirely to MacOS and have not used flexASIO in ages, let alone worked on the repo...

Hi! Bit late to the party...

I've also moved away from Windows some time ago (and stopped using flexASIO long before that).

I did, however, try to run this in a VM and got the following:

[output]
device = "Динамики (High Definition Audio Device)\u0000"

Note the \u0000 at the end that was not here before - looks like an off-by-1 error to me...

This trailing zero comes from Portaudio and only for this Cyrillic-named device in my case, so there's got to be some weirdness in there.

This is a P/Invoke issue, I upgraded the dependency library to support UTF-8 string, it's fixed now.

Also, along the way I fixed the issue where the program failed to start when configuration files were read incorrectly (#42), now it automatically resets them on configuration errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants